<!-- 班次 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班次</title>
</head>
<body>

	<div id="hjj-bt-classesNum" style="padding: 5px; height:auto">
			<!-- 添加 -->
			<my:g id="58"><a id="hjj-bt-classesNum-insert" href="JavaScript:holidayTypeAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',text:'新增'"></a></my:g>
			
			<a id="shift_reload"class="easyui-linkbutton" data-options="iconCls:'icon-reload'"></a>
			
			
			搜索文本	<a id="shift-text" class="easyui-textbox" data-options="width:200"></a>
			<a id="shift-sousuo" class="easyui-linkbutton" data-options="iconCls:'icon-search',text:'搜索'"></a>
	</div>
	
	<table id="hjj-class-dg"  class="easyui-datagrid" 
        data-options="
        fitColumns:true,
        fit:true,
        border:false,
        singleSelect:true,
        autoRowHeight:true,
         <!-- 分页 -->
		pagination:true,
		<!-- ulr: -->
		url:'to_shift_all',
		method:'get',
		pageSize:5,
		pageList:[5,10,15,20],
		pagePosition:'bottom',
		toolbar:'#hjj-bt-classesNum'
        "
		>   
    <thead>   
        <tr>   
        	<th data-options="field:'shiftId',width:50" align="center">编号</th>
        	<th data-options="field:'shiftName',width:80" align="center">名称</th>
        	<th data-options="field:'shiftCategory',width:90" align="center">类别</th>   
        	<th data-options="field:'shiftRemarks',width:140" align="center">备注</th>
        	<th data-options="field:'shiftPerson',width:80" align="center">创建者</th>
        	<th data-options="field:'shiftFounddate',width:110,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}" align="center">创建日期</th> 
        	<th data-options="field:'shiftUpdate',width:110,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}" align="center">更新日期</th>  
        	<th data-options="field:'shiftState',width:30,formatter:shift_state" align="center">关闭</th>  
        	<th data-options="field:'xxxx',width:70,formatter:shiftformatter"></th> 	
		</tr>   	
    </thead>   
	</table>  
	 <script type="text/javascript">
	 var shift_state= function(value,row,index){
			var pic="";
			var state = row.shiftState;
			if(state==0){
				pic = "<input type='checkbox' disabled='disabled'>";
			}else if(state==1){
				pic="<input type='checkbox' checked disabled='disabled'>";
			}
			return pic;
		}
	 /*  编辑按钮 */
	   function shiftformatter(value, row, index){
		   var block ="";
		   var edit ="";
		   var remove ="";
		  <my:g id="59">block = "<a  onclick='toBlock(" + row.shiftId + ","+row.shiftState+")' class='cell_btn_block' href='#'></a>";</my:g>
		   
		  <my:g id="60"> edit = "<a  onclick='toEditRole(" + row.shiftId + ")' class='cell_btn_edit' href='#'></a>";</my:g>
               
		  <my:g id="61">remove = "<a  onclick='deleteRole(" + row.shiftId +")' class='cell_btn_del' href='#'></a>";</my:g>

           return block + edit + remove ;

       };
	  /*  编辑按钮图标 */
	 	$(function(){
	 		$("#hjj-class-dg").datagrid({onLoadSuccess: function(){
				$(".cell_btn_block").linkbutton({iconCls:'icon-changes', plain:true});
				$(".cell_btn_edit").linkbutton({iconCls:'icon-update_red', plain:true});
				$(".cell_btn_del").linkbutton({iconCls:'icon-delete_red', plain:true});
			}});
			
	 	})
	 	/*新增*/
	 	function holidayTypeAdd(){
					$('#hjj-shift-dlg1').dialog('open').dialog('center');
		}
	 	//刷新
		$("#shift_reload").linkbutton({
			onClick:function(){
				$('#hjj-class-dg').datagrid('reload');
			}
		});	
	 	/* 删除 */
		var deleteRole= function(Id){
			/* $('#hjj-holidayType-dlg-edit').dialog("close"); */
			$.messager.confirm('确认','您确认要删除班次吗？',function(v){
				if(v){
					$.post("is_del_shift",{shiftId:Id},function(v){
						if(v.success){
							$('#hjj-class-dg').datagrid('reload');
						}else{
							$.messager.alert('错误',v.message);
						}
					});
				}else{
					
				}
				
			});
		}
		/*禁用*/
		var toBlock =function(id,State){
			/* $('#hjj-holidayType-dlg-edit').dialog("close"); */
			var jy_state =1;
			if(State==1){
				jy_state=0;
				$.messager.confirm('确认', '您确定要打开该班次吗？', function(v){
					if(v){
						$.post("update_shift_state", {shiftId: id,shiftState:jy_state}, function(v){
							if(v.success){
								$('#hjj-class-dg').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}else if(State==0){
				jy_state=1;
				$.messager.confirm('确认', '您确定要关闭该班次吗？', function(v){
					if(v){
						$.post("update_shift_state", {shiftId: id,shiftState:jy_state}, function(v){
							if(v.success){
								$('#hjj-class-dg').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}
		}
	  	/* 编辑 */
	  	function toEditRole(id){
	  		$('#hjj-shift-ff-edit').form('load','load_shift?shiftId='+id);
	  		$('#hjj-shift-dlg-edit').dialog('open');
	  		
	  	}
	  	//双击编辑
	  	//双击修改
			<my:g id="60">$('#hjj-class-dg').datagrid({
				onDblClickRow: function(index, row){
					$('#hjj-shift-dlg-edit').dialog("open");
					$('#hjj-shift-ff-edit').form('load','load_shift?shiftId='+row.shiftId);
				}
			});
			</my:g>
	  //模糊搜索
		$("#shift-sousuo").linkbutton({
			onClick:function(){

				var SeeText = $("#shift-text").textbox("getText");
				 $("#hjj-class-dg").datagrid({url:'to_isshiftByName?shiftName='+SeeText,method:'get'});
				$("#hjj-class-dg").datagrid("reload"); 
			}
		});
	 </script>
	 <!--  新增 -->
	<div id="hjj-shift-dlg1" class="easyui-dialog" style="padding:20px 20px;width:450px;"
	 data-options="inline:true,modal:true,closed:true,title:'新增班次',iconCls:'icon-save',
		buttons:[{
					text:'保存',
					iconCls:'icon-add',
					handler:function(){
						<!-- 提交 -->
						$('#hjj-shift-ff').form('submit', {    
						      url:'is_add_shift',
						      method:'post',
						    onSubmit: function(param){   
						    	param['shiftName']=$('#shifttypeName').textbox('getText');
						    	param['shiftCategory']=$('.shifttypeIsemolument').val();
						    	param['shiftRemarks']=$('#shiftremake').textbox('getText');
						    	if($('#isshiftstop').is(':checked')){
						    		param['shiftState']=parseInt(1);
						    	}else{
						    		param['shiftState']=parseInt(0);
						    	}
						       return $('#hjj-shift-ff').form('validate');
						    },    
						    success:function(v){   
						    
						      if(v){
						      $('#hjj-shift-dlg1').dialog('close')
						      $('#hjj-shift-ff').form('clear')
						      $('#hjj-class-dg').datagrid('reload')
						     }else{
						     	$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
						     }
						    }    
						});  
												
					
					}
				},{
					text:'关闭',
					iconCls:'icon-cancel',
					handler:function(){
						$('#hjj-shift-dlg1').dialog('close')
					}
				}]
				
				
		">
		<form id="hjj-shift-ff"  method="post">
	
			<div style="margin-bottom:10px">
				<input id="shifttypeName" class="easyui-textbox" data-options="label:'名称：',required:true"  prompt="请输入" style="width:80%;height:25px">
			</div>
			
			<div style="margin-bottom:10px">
				<select id="hjj-cc-shift" class="easyui-combobox shifttypeIsemolument" data-options="label:'类别：',panelHeight:'auto'"  style="width:80%;">   
   					 	<option value=" "> </option>   
  						<option value="常日班">常日班</option>
  						<option value="早班">早班</option>  
  						<option value="中班">中班</option>  
  						<option value="晚班">晚班</option>     
				</select>  
			</div>
			
			<div>
				<input class="easyui-textbox" data-options="label:'备注：',multiline:true,height:100,width:'90%'" id="shiftremake"/>
			</div>
			&nbsp&nbsp
			&nbsp&nbsp
			<div style="margin-bottom:10px">
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				停用:
				&nbsp&nbsp
				&nbsp&nbsp
				
				<input type="checkbox" value="停用"id="isshiftstop"/>
			</div>
			
			
		</form>	
	</div>
	<!-- 编辑 -->
	<div id="hjj-shift-dlg-edit" class="easyui-dialog" style="padding:20px 20px;width:450px;"
	 data-options="inline:true,modal:true,closed:true,title:'编辑班次',iconCls:'icon-save', 
		buttons:[{
					text:'保存',
					iconCls:'icon-ok',
					handler:function(){
						<!-- 提交 -->
						$('#up-shift').form('submit', {    
						    url:'is_update_shift',
						    onSubmit: function(param){
						    	param['shiftId']= $('#shiftIds').textbox('getText');   
						    	param['shiftName']=$('#shifttypeNames').textbox('getText');
						    	param['shiftCategory']=$('.shiftIsemoluments').val();
						    	param['shiftRemarks']=$('#holidayremakes').textbox('getText');
						    	if($('#isshiftstops').is(':checked')){
						    		param['shiftState']=parseInt(1);
						    	}else{
						    		param['shiftState']=parseInt(0);
						    	}
						       return $(this).form('validate');
						    },    
						    success:function(v){    
						      <!-- 提交关闭 -->  
						      if(v){
						      $('#hjj-shift-dlg-edit').dialog('close')
						 
						      $('#hjj-class-dg').datagrid('reload')
						      }else{
						      		$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
						      }
						    }    
						});  
												
					
					}
				},{
					text:'关闭',
					iconCls:'icon-cancel',
					handler:function(){
						$('#hjj-shift-dlg-edit').dialog('close')
					}
				}]
				
				
		">
		<form id="hjj-shift-ff-edit"  method="get">
			<!-- 隐藏ID -->
			<input type="hidden" class="easyui-textbox" id="shiftIds" name="shiftId">
			
			<div style="margin-bottom:10px">
				<input  id="shifttypeNames" name="shiftName" class="easyui-textbox" data-options="label:'名称：'"  prompt="请输入" style="width:80%;height:25px">
			</div>
			<div style="margin-bottom:10px">
				<select id="hjj-cc-shifts" class="easyui-combobox shiftIsemoluments" data-options="label:'薪资处理：',panelHeight:'auto'" name="shiftCategory" style="width:80%;">   
   					 	<option value=" "> </option>   
  						<option value="常日班">常日班</option>
  						<option value="早班">早班</option>  
  						<option value="中班">中班</option>  
  						<option value="晚班">晚班</option>     
				</select>  
			</div>
			<div>
				<input id="holidayremakes" name="shiftRemarks" class="easyui-textbox " data-options="label:'备注：',multiline:true,height:100,width:'90%'" />
			</div>
				&nbsp&nbsp
			&nbsp&nbsp
			<div style="margin-bottom:10px">
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				&nbsp&nbsp
				停用:
				&nbsp&nbsp
				&nbsp&nbsp
				
				<input type="checkbox" id="isshiftstops" value="1" name="shiftState"/>
			</div>
		</form>	
	</div>
	<div>
		<form method="post" id="up-shift"></form>
	</div>
</body>
</html>